<template>
  <tbody>
    <tr v-for="(item, index) in goodList" :key="item.name">
      <td>
        <input
          type="checkbox"
          name=""
          id=""
          v-model="item.checked"
:value="item.checked"
@click="inputtrue(index)"
        />
      </td>
      <td>{{ item.name }}</td>
      <td>{{ item.price }}</td>
      <td>
        <button @click="onSub(index)">-</button>
        {{ item.num }}
        <button @click="onAdd(index)">+</button>
      </td>
      <td>{{ item.price * item.num }}</td>
      <td><button @click="onDel(index)">删除</button></td>
    </tr>
  </tbody>
</template>

<script>
import { mapState, mapMutations } from 'vuex'

export default {
  data () {
    return {}
  },

  created () {},

  methods: {
    ...mapMutations(['addCount', 'subCount', 'delData', 'editInputSamll']),
    onAdd (index) {
      this.addCount(index)
    },
    onSub (index) {
      this.subCount(index)
    },
    onDel (index) {
      this.delData(index)
    },
    inputtrue (index) {
      console.log(!this.goodList[index].checked)
      this.editInputSamll(index)
    }

  },
  computed: {
    ...mapState(['goodList'])

  }
}
</script>

<style scoped lang="less"></style>
